package com.yanqu.road.server.cmd;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.union.UnionActivityGroupProto;
import com.yanqu.road.utils.YanQuMessageUtils;
import io.netty.channel.ChannelHandlerContext;

public abstract class CrossUnionCommand extends CrossCommand {

    protected int activityId;
    protected int groupId;

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage basePacket) throws Exception {

        // 解析商会活动分组协议
        UnionActivityGroupProto.BaseUnionActivityGroupMsg baseMsg = UnionActivityGroupProto.BaseUnionActivityGroupMsg.parseFrom(basePacket.getBytes());
        activityId = baseMsg.getActivityId();
        groupId = baseMsg.getGroupId();
        YanQuMessage packet = YanQuMessageUtils.buildMessageByte(baseMsg.getCode(), baseMsg.getMsg().toByteArray());
        packet.setPlayerId(basePacket.getPlayerId());

        super.execute(ctx, packet);
    }

}
